package druid;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.util.Properties;

/**
 * 数据库连接池演示
 */
public class DruidDemo {
    public static void main(String[] args) throws Exception {
        //导入jar包,定义配置文件
        //加载配置文件
        Properties prop = new Properties();
        prop.load(new FileInputStream("jdbc-demo/src/druid.properties"));

        //获取连接池对象
        DataSource ds = DruidDataSourceFactory.createDataSource(prop);

        //从连接池获取连接对象
        Connection con = ds.getConnection();
        System.out.println(con);

//        System.out.println(System.getProperty("user.dir"));
    }
}
